﻿using CMN.Common;
using System.Collections.Generic;
namespace CMN.Config
{
    /// <summary>
    /// CachePrefix配置信息类文件
    /// </summary>
    public class WebAppCacheConfigInfo : IConfigInfo
    {
        private List<WebAppCacheInfo> webAppCacheInfos = new List<WebAppCacheInfo>();

        /// <summary>
        /// 缓存前缀列表
        /// </summary>
        public List<WebAppCacheInfo> WebAppCacheInfos
        {
            get { return webAppCacheInfos; }
            set { webAppCacheInfos = value; }
        }
            

        /// <summary>
        /// 获得缓存前缀
        /// </summary>
        /// <param name="prefix"></param>
        /// <returns></returns>
        public WebAppCacheInfo GetWebAppCacheInfo(string prefix)
        {

            WebAppCacheInfo Info = new WebAppCacheInfo();
            for (int i = 0; i < WebAppCacheInfos.Count; i++)
            {
                if (WebAppCacheInfos[i].Prefix == prefix)
                {
                    Info = WebAppCacheInfos[i];
                    break;
                }
            }
            return Info;
        }
    }

    public class WebAppCacheInfo
    {
        /// <summary>
        /// 前缀名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 缓存前缀
        /// </summary>
        public string Prefix { get; set; }

        /// <summary>
        /// 缓存时间（分钟数）
        /// </summary>
        public int CacheTime { get; set; }
    }

    
}
